abstract type AbstractDevice end
abstract type Sensor <: AbstractDevice end
abstract type Acutator <: AbstractDevice end

struct Device{T}
    kind::T
    name::String
    tag::Ptr{WbDeviceTag}
    function Device{T}(name::String) where {T}
        tag = @ccall lib.wb_robot_get_device(name::Cstring)::Ptr{WbDeviceTag}
        new{T}(T(), name, tag)
    end
end

type(::Type{T}) where T = :dev
Base.eltype(::Device{T}) where T = T

function enable(dev::Device{T}, sampling_period) where T
    func = Libdl.dlopen(lib) do dl
        Libdl.dlsym(dl, Symbol(:wb_, type(T), :_enable))
    end
    ccall(func, Cvoid, (Ptr{WbDeviceTag}, Cint), dev.tag, sampling_period)
end

function disable(dev::Device{T}) where T
    func = Libdl.dlopen(lib) do dl
        Libdl.dlsym(dl, Symbol(:wb_, type(T), :disable))
    end
    ccall(func, Cvoid, (Ptr{WbDeviceTag}, ), dev.tag)
end
